<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>订单列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="{{URL::asset('layui/css/layui.css')}}"  media="all">
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body>
<fieldset class="layui-elem-field" style="margin-top: 20px;">
    <legend>搜索查询</legend>
    <form class="layui-form" action="">

        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">订单号</label>
                <div class="layui-input-inline">
                    <input type="text" name="order_sn" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">收件人</label>
                <div class="layui-input-inline">
                    <input type="text" name="username"  autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">联系电话</label>
                <div class="layui-input-inline">
                    <input type="text" name="phone"  autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">收货地址</label>
                <div class="layui-input-inline">
                    <input type="tel" name="address"  autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">订单状态</label>
                <div class="layui-input-inline">
                    <select name="order_status" lay-filter="aihao">
                        <option value="all">全部</option>
                        <option value="0">待支付</option>
                        <option value="1">待发货</option>
                        <option value="2">待收货</option>
                        <option value="3">已签收</option>
                        <option value="4">已评价</option>
                        <option value="7">已退款</option>
                        <option value="-1">已取消</option>
                    </select>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">支付方式</label>
                <div class="layui-input-inline">
                    <select name="payment" lay-filter="aihao">
                        <option value="all">全部</option>
                        <option value="integral">积分支付</option>
                        <option value="wechat">微信支付</option>
                    </select>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">开始时间</label>
                <div class="layui-input-inline">
                    <input type="text" name="start_date" id="date1" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">结束日期</label>
                <div class="layui-input-inline">
                    <input type="text" name="end_date" id="date2" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-input-inline">
                    <button class="layui-btn" lay-submit="" lay-filter="demo1">搜索</button>
                </div>
            </div>
        </div>
    </form>
</fieldset>




<table class="layui-hide" id="test" lay-filter="test"></table>


<script src="{{URL::asset('layui/layui.js')}}" charset="utf-8"></script>
<script src="{{URL::asset('js/jquery-3.1.1.min.js')}}"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->

<script>
    layui.use(['table','form','laydate'], function(){
        var table = layui.table,
            laydate = layui.laydate,
            form = layui.form;

        //日期
        laydate.render({
            elem: '#date1'
        });
        laydate.render({
            elem: '#date2'
        });

        table.render({
            elem: '#test'
            ,url:'/admin/order/api/list'
            ,title: '订单数据表'
            ,cols: [[
                {type: 'checkbox', fixed: 'left'}
                ,{field:'id', title:'ID', width:80, fixed: 'left', unresize: true, sort: true}
                ,{field:'order_sn', title:'订单号'}
                ,{field:'order_amount', title:'订单金额'}
                ,{field:'pay_amount', title:'实付金额'}
                ,{field:'payment', title:'支付方式',templet:function (d) {
                        if (d.payment=='wechat'){
                            return '微信支付';
                        } else {
                            return '积分支付';
                        }
                    }}
                ,{field:'goods_num', title:'购买数量'}
                ,{field:'username', title:'收件人'}
                ,{field:'phone', title:'联系电话'}
                ,{field:'order_status', title:'订单状态',templet:function (d) {
                        if (d.order_status==0){
                            return '待支付';
                        } else if(d.order_status==1) {
                            return '待发货';
                        } else if (d.order_status==2){
                            return '待收货';
                        } else if (d.order_status==3){
                            return '已签收';
                        } else if (d.order_status==4){
                            return '已评价';
                        } else if (d.order_status==7){
                            return '已退款';
                        } else if(d.order_status==-1){
                            return '已取消';
                        } else {
                            return '状态异常';
                        }
                    }}
                ,{field:'order_time', title:'下单时间'}
            ]]
            ,page: true
        });


        //监听提交
        form.on('submit(demo1)', function(data){
            var param = data.field;
            //执行重载
            table.reload('test', {
                page: {
                    curr: 1 //重新从第 1 页开始
                }
                ,where: {
                    order_sn: param.order_sn,
                    phone:param.phone,
                    username:param.username,
                    address:param.address,
                    order_status:param.order_status,
                    payment:param.payment,
                    start_date:param.start_date,
                    end_date:param.end_date
                }
            });
            return false;
        });

    });
</script>

</body>
</html>